require('koa-passport')


//定义允许直接访问的url
const allowpage = ['/user','/api/user/login','/api/user/register']
//拦截
function localFilter(ctx) {
    let url = ctx.originalUrl
    if (allowpage.indexOf(url) > -1) {
        logger.info('当前地址可直接访问')
    }else {
        if (ctx.isAuthenticated()) {
            // if(url==='/'){
            //     ctx.redirect('/projectList')
            // }
            console.log('login status validate success')
        } else {
            console.log('login status validate fail')
            console.log(ctx.request.url)
            ctx.redirect('/login')
        }
    }
}

module.exports=localFilter